package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.entity.SetmealDish;
import com.example.mapper.SetmealDishMapper;
import com.example.service.ISetmealDishService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 套餐菜品关系 服务实现类
 * </p>
 *
 * @author czx
 * @since 2022-04-28
 */
@Service
public class SetmealDishServiceImpl extends ServiceImpl<SetmealDishMapper, SetmealDish> implements ISetmealDishService {

    /**
     * 根据套餐id查询套餐中菜品数据
     *
     * @param setmealId 套餐id
     * @return 套餐中的菜品
     */
    @Override
    public List<SetmealDish> getBySetmealId(Long setmealId) {
        LambdaQueryWrapper<SetmealDish> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SetmealDish::getSetmealId, setmealId);
        return this.list(wrapper);
    }

    /**
     * 根据套餐id删除
     *
     * @param setmealIds 套餐id
     * @return 删除结果
     */
    @Override
    public boolean removeBySetmealIds(List<Long> setmealIds) {
        LambdaQueryWrapper<SetmealDish> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SetmealDish::getSetmealId, setmealIds);
        return this.remove(wrapper);
    }

    /**
     * 根据套餐id删除
     *
     * @param setmealId 套餐id
     * @return 删除结果
     */
    @Override
    public boolean removeBySetmealId(Long setmealId) {
        LambdaQueryWrapper<SetmealDish> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SetmealDish::getSetmealId, setmealId);
        return this.remove(wrapper);
    }
}
